import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:squat_easy/generated/assets.dart';
import 'package:squat_easy/se_route.dart';
import 'package:ylm_ui_kit/ylm_ui_kit.dart';

class SeMineBasePage extends StatelessWidget {
  const SeMineBasePage({super.key, required this.child, this.showBack = true, this.title, this.actions});

  final Widget child;
  final Widget? title;
  final List<Widget>? actions;
  final bool showBack;

  @override
  Widget build(BuildContext context) {
    return BaseScaffold(
      resizeToAvoidBottomInset: false,
      child: Stack(
        fit: StackFit.expand,
        children: [
          _buildBg().positioned(
            top: 0,
            left: 0,
            right: 0,
            bottom: -(50.w + ScreenUtil().bottomBarHeight * 0.5),
          ),
          Stack(
            alignment: Alignment.center,
            children: [
              Row(
                children: [
                  if (showBack) _buildBack(),
                  const Spacer(),
                  if ((actions ?? []).isNotEmpty) ...actions!,
                ],
              ),
              if (title != null) title!,
            ],
          ).positioned(top: 110.w, left: 33, right: 33),
          child.paddingTop(200.w),
        ],
      ),
    );
  }

  Widget _buildBg() => const IconWidget.image(Assets.pngMineBg1, fit: BoxFit.fill);

  Widget _buildBack() => ButtonWidget.icon(
        Assets.svgAppBarBack.toSvg(width: 40),
        onTap: SeRoute.close,
      );
}
